package org.eclipse.wtp.sample.calculator;

import java.io.IOException;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class CalculatorServlet extends HttpServlet implements Servlet {

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doPost(req, resp);
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doGet(req, resp);
		HttpSession session = req.getSession(true);
		System.out.println("Blah");
		double a = Double.parseDouble(req.getParameter("inputA"));
		double b = Double.parseDouble(req.getParameter("inputB"));
		double c = Double.parseDouble(req.getParameter("inputC"));
		double result = 0;
		String buttonPressed = req.getParameter("oper");
		Calculator calc = new Calculator();
		System.out.println("Stuff goes here, ok");
		System.out.println("hlksdlfkjsf");
		System.out.println("hey Ryan");
		if (buttonPressed == "*")
			result = calc.Mult(a, b);
			session.setAttribute("result",result);
	}
	
}
